def solve(n):
    def get_next(number):
        sum = 0
        while number > 0:
            temp = number % 10
            sum += temp ** 2
            number //= 10

        return sum

    seen = set()
    while n != 1 and n not in seen:
        seen.add(n)
        n = get_next(n)

    return n == 1


if __name__ == "__main__":
    number = 2
    if solve(2):
        print(f"{number}是快乐数")
    else:
        print(f"{number}不是快乐数")
